var map;
var rendererOptions = {
  draggable: true
};
var directionsDisplay;

function createMap(lat, lng, domID, getTraffic) {
	directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
	var warehouse = new google.maps.LatLng(lat, lng);
	var myOptions = {
		zoom :12,
		center :warehouse,
		mapTypeId :google.maps.MapTypeId.ROADMAP
	};

	map = new google.maps.Map(document.getElementById(domID),
			myOptions);
	
	directionsDisplay.setMap(map);
	
	if(getTraffic=="google"){
		var trafficLayer = new google.maps.TrafficLayer();
		trafficLayer.setMap(map);
	}else if(getTraffic=="traffy"){
		var Overlay  = new missouristate.web.TileOverlay(
            function(x, y, z) { 
            	//return   "http://athena.traffy.in.th/apis/apitraffy.php?format=png&api=getTile&key=fX6bCBZQxP&appid=00000031&x=" + x + "&y=" + y + "&z=" + z ; 
            	return   "http://athena.traffy.in.th/apis/apitraffy.php?format=png&api=getTile&key=AibgZsBJdV&appid=00001368&x=" + x + "&y=" + y + "&z=" + z ;
            },
            {
                'map': map, // optional. google.maps.Map reference.
                'visible': true, //optional. boolean. controls initial display of the layer.
                'minZoom': 1, // optional. minimum zoom level at which the tile layer will display.
                'maxZoom': 19, //optional. maximum zoom level at which the tile layer will display.
                'mapTypes': [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID], //optional. If present, tiles will only be drawn when the map type matches
                'percentOpacity': 80 //optional. Initial opacity percentage of the overlay.
            }
        );
	}
}
